import request from '@/utils/request'

export function list() {
  return request({
    url: 'api/agentDef/selectPages',
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: 'api/agentDef/add',
    method: 'post',
    data
  })
}

export function edit(data) {
  return request({
    url: 'api/agentDef',
    method: 'put',
    data
  })
}

export function del(data) {
  return request({
    url: 'api/agentDef',
    method: 'delete',
    data
  })
}

export function updateAgentStatus(data) {
  return request({
    url: 'api/agentDef/updateAgentStatus',
    method: 'post',
    data
  })
}
export function updateAgentHaStatus(data) {
  return request({
    url: 'api/agentDef/updateAgentHaStatus',
    method: 'post',
    data
  })
}

export function checkConnect(data) {
  return request({
    url: 'api/agentDef/checkConnect',
    method: 'post',
    data
  })
}

export function selectAgentStates(agentCode) {
  return request({
    url: 'api/runningStateLog/selectAgentStates?agentCode=' + agentCode,
    method: 'get'
  })
}

export function selectApplogsByCode(data) {
  return request({
    url: 'api/appLog/selectApplogsByCode',
    method: 'post',
    data
  })
}

export function checkRepeatCode(data) {
  return request({
    url: 'api/agentDef/checkRepeatCode',
    method: 'post',
    data
  })
}

export function qryHaveApp(agentCode) {
  return request({
    url: 'api/agentDef/qryHaveApp?agentCode=' + agentCode,
    method: 'get'
  })
}

export function qryPwdByCode(agentCode) {
  return request({
    url: 'api/agentDef/qryPwdByCode?agentCode=' + agentCode,
    method: 'get'
  })
}

export function selectDiscByCode(agentCode) {
  return request({
    url: 'api/agentHeartbeatLog/selectDiscByCode?agentCode=' + agentCode,
    method: 'get'
  })
}

export function checkRepeatName(data) {
  return request({
    url: 'api/agentDef/checkAgentName',
    method: 'post',
    data
  })
}

export function checkAgentIP(data) {
  return request({
    url: 'api/agentDef/checkAgentIP',
    method: 'post',
    data
  })
}

export function getAgentList() {
  return request({
    url: 'api/agentDef/getAgentList',
    method: 'get'
  })
}

export function getAgentSessionTask(data) {
  return request({
    url: 'api/agentDef/getAgentSessionTask',
    method: 'post',
    data
  })
}

export function downloadAgentLog(params) {
  return request({
    url: 'api/agentDef/downloadAgentLog?agentCode=' + params.agentCode + '&agentIp=' + params.agentIp +
    '&agentPort=' + params.agentPort,
    method: 'get',
    responseType: 'blob'
  })
}

export function getMemoryObjInfoList(agentCode) {
  return request({
    url: 'api/agentHeartbeatLog/getMemoryObjInfoList?agentCode=' + agentCode,
    method: 'get'
  })
}

export function qryCatalogue(data) {
  return request({
    url: 'api/agentDef/qryCatalogue',
    method: 'post',
    data
  })
}

export function previewLog(data) {
  return request({
    url: 'api/agentDef/previewLog',
    method: 'post',
    data
  })
}

export function getAgentPath(data) {
  return request({
    url: 'api/agentDef/getAgentPath',
    method: 'post',
    data
  })
}

export function checkPort(data) {
  return request({
    url: 'api/agentDef/checkPort',
    method: 'post',
    data
  })
}

export function qryAgentSessionInfo(agentCode) {
  return request({
    url: 'api/agentDef/qryAgentSessionInfo/' + agentCode,
    method: 'get'
  })
}

export default { add, list, del, edit, updateAgentStatus, checkConnect, selectAgentStates, selectApplogsByCode,
  checkRepeatCode, qryHaveApp, qryPwdByCode, selectDiscByCode, checkRepeatName, getAgentList, getAgentSessionTask, downloadAgentLog,
  getMemoryObjInfoList, checkAgentIP, qryCatalogue, previewLog, getAgentPath, checkPort, qryAgentSessionInfo }
